﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Example03.aspx.cs" Inherits="Chapter40.Example03" %>

<!DOCTYPE html>

<html manifest="Example02.txt">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>代码清单 40-3 关联清单文件与 HTML 文档</title>
    <meta name="author" content="Adam Freeman" />
    <meta name="description" content="A simple example" />
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    <style>
        img {
            border: medium double black;
            padding: 5px;
            margin: 5px;
        }
    </style>
</head>
<body>
    <img id="target" src="images/bananas.jpg" alt="bananas" />
    <div>
        <button id="bananas">Bananas</button>
        <button id="apples">Apples</button>
        <button id="cherries">Cherries</button>
    </div>
    <script>
        var buttons = document.getElementsByTagName('button');
        for (var i = 0; i < buttons.length; i++) {
            buttons[i].onclick = handleButtonPress;
        }

        function handleButtonPress(e) {
            document.getElementById('target').src = 'images\\' + e.target.id + '.jpg';
        }
    </script>
</body>
</html>
